package Engine.ParticelSystem;

import static org.lwjgl.opengl.GL11.*;

import java.util.ArrayList;

import org.lwjgl.opengl.GL11;

import Engine.Engine;
import Engine.RenderObject;
import Engine.PhysicEngine.PhysicObject;

public class ParticleEmitter extends RenderObject {

	private boolean IsConfigured = false;
	private ParticleConfiguration particleconfig = null;
	private Engine engine;
	private java.util.List<Particle> particles;
	public int XPosition = 100;
	public int YPosition = 200;

	public ParticleEmitter(Engine engine) {
		this.engine = engine;

		particles = new ArrayList<Particle>();
	}

	public void RenderObject_draw() {
		if (!particleconfig.isUseAlphaBlending())
			glBlendFunc(GL_SRC_ALPHA, GL_ONE);
		
		glPushMatrix();
		glTranslatef(XPosition, YPosition, 0);
		for (Particle item : particles) {
			item.Draw(engine.time);
		}
		glPopMatrix();

	}
	
	@Override
	public void RenderObject_gui() {
		// TODO Auto-generated method stub
		
	}

	public void RenderObject_init() {
		particleconfig.Init();
	}

	public ParticleConfiguration getParticleconfig() {
		return particleconfig;
	}

	public void setParticleconfig(ParticleConfiguration particleconfig) {
		this.particleconfig = particleconfig;
		particles = new ArrayList<Particle>();
		for (int i = 0; i < getParticleconfig().getParticleCount(); i++)
			particles.add(new Particle(getParticleconfig()));
	}

}
